<template>
	<view v-if="msg==''">
		<xbd-zwnz marginTop='200'></xbd-zwnz>
	</view>
	<view v-else class="center">
		<view class="title">
			{{msg.title}}
		</view>
		<view class="details">
			<view class="">
				<view class="tag">
					发布人：{{msg.creator}}
				</view>
				<view class="tag">
					发布时间：{{msg.time | timeFormat('YYYY-MM-DD HH:mm')}}
				</view>
			</view>
		</view>
		<view class="tag">
			预警事项
		</view>
		<view class="text">
			{{msg.title}}
		</view>
		<view class="tag">
			预警意见
		</view>
		<view class="text">
			{{msg.view}}
		</view>
		<view class="tag">
			防控措施
		</view>
		<view class="text">
			{{msg.measures}}
		</view>
		<xbd-button v-if="!state" text="确认" @clickBtn="cancel()"></xbd-button>
	</view>
</template>

<script>
	import {
		Personalcenter
	} from '@/api/index.js';
	import XbdButton from '@/components/common/xbd-button.vue'
	export default {
		data() {
			return {
				id:'',
				msg:"",
				state:''
			};
		},
		components: {
			XbdButton
		},
		methods:{
			click(){
				console.log('确认')
			},
			async cancel(){
				const res =await Personalcenter.posMessageRead(this.id)
				if(res.success){
					this.state = true
					uni.$emit('isread',this.id)
				}
				this.$showToast(res.msg);
			},
			async init(){
				const res =await Personalcenter.getMessageDetail(this.id)
				if(res.success){
					this.msg=res.data.detail
					this.state=res.data.state
				}
				
				if(res.code == 9007){
					this.$showToast(res.msg);
				}
				console.log(res,'res')
			}
		},
		onLoad(res){
			this.id=res.id
			this.init()
		}
	}
</script>

<style lang="scss" scoped>
	
.center{
	padding: 32rpx;
	.title{
		font-family: PingFang SC, PingFang SC-Heavy;
		font-weight: 800;
		line-height: 56rpx;
		font-size: 32rpx;
		color: #000623;
		text-align: justify;
		word-wrap: break-word;
		}
	.details{
		margin-top: 30rpx;
		padding-bottom: 40rpx;
		display:flex;
		justify-content: space-between;
		font-size: 26rpx;
		color: #8890A5;
		align-items: center;
		border-bottom: 2rpx solid #EBEEF5;
		margin-bottom: 40rpx;
	}
	.tag{
		margin-bottom: 10rpx;
		font-size: 26rpx;
		color: #8890A5;
	}
	
	.text{
		margin-bottom: 40rpx;
		font-size: 30rpx;
	}
}
</style>
